/**
 * Created by forcht on 2018/5/1.
 */
public class Solution {
    public int jump(int[] A) {
        int[] dp = new int[A.length];
        dp[A.length - 1] = 0;
        for (int i = A.length - 2; i >= 0; i--) {
            int t = A[i];
            int min = Integer.MAX_VALUE;
            for (int j = i + 1; j < A.length && j <= i + t; j++) {
                if (dp[j] < min) min = dp[j];
            }
            if (min < Integer.MAX_VALUE) dp[i] = min + 1;
            else dp[i] = Integer.MAX_VALUE;
        }
        return dp[0];
    }
}
